import http from '../utils/http'
// 
/**
 *  @parms resquest 请求地址 例如：http://197.82.15.15:8088/request/...
 *  @param '/testIp'代表vue-cil中config，index.js中配置的代理
 */

//请求示例
//let resquest = "/api/auth/login"

// // get请求
// export function getListAPI(params){
//     return http.get(`${resquest}/getList.json`,params)
// }
// // post请求
// export function postFormAPI(params){
//     return http.post(`${resquest}/postForm.json`,params)
// }
// // put 请求
// export function putSomeAPI(params){
//     return http.put(`${resquest}/putSome.json`,params)
// }
// // delete 请求
// export function deleteListAPI(params){
//     return http.delete(`${resquest}/deleteList.json`,params)
// }

//用户管理
let loginUri = "/api/auth/login"
let userProfileUri="/api/user/profile"
let userModifyUri="/api/user/modify"
let userListUri="/api/user/list"
let userModifyByIdUri="/api/user/{userid}/modify"
let userDeleteByIdUri="/api/user/{userid}"
let userAddUri="/api/user/add"
let userChangePassUri="/api/user/change-password"

let roleListUri="/api/role/list"
let roleModifyByIdUri="/api/role/{roleid}/modify"
let roleDeleteByIdUri="/api/role/{roleid}"
let roleAddUri="/api/role/add"
let roleSecurityUri="/api/role/{roleid}/securities"

let securityListUri="/api/security/list"
let securityAllUri="/api/security/all"
let securityGiveRoleUri="/api/security/give/{roleid}"

let roleAllUri="/api/role/all"
let userRoleUri="/api/user/{userid}/roles"
let roleGiveUserUri="/api/role/give/{userid}"

//系统中心
let sysCategoryAllUri="/api/sysdata/categories"
let sysCategoryInfoUri="/api/sysdata/{categoryid}/category"
let sysCategoryModifyUri="/api/sysdata/{categoryid}/modify"
let sysCategoryAddUri="/api/sysdata/add"

let sysDataByCateIdUri="/api/sysdata/{categoryid}/data"
let sysDataAddUri="/api/sysdata/{categoryid}/dictionary-data"
let sysDataDeleteUri="/api/sysdata/{categoryid}/dictionary-data"
let sysDataModyfyByIdUri="/api/sysdata/{categoryid}/dictionary-data/{dataid}"

// 登录请求
export function loginAPI(params){
    return http.post(loginUri,params)
}

//获取当前用户信息
export function userProfileAPI(){
    return http.get(userProfileUri)
}

//修改当前用户信息
export function userModifyAPI(params){
    return http.put(userModifyUri,params)
}

//获取用户列表
export function userListAPI(params){
    return http.get(userListUri,params)
}

//修改指定用户信息
export function userModifyByIdAPI(userid,params){
    let _userModifyByIdUri=userModifyByIdUri.replace('{userid}',userid)
    return http.put(_userModifyByIdUri,params)
}

//删除指定用户信息
export function userDeleteByIdAPI(userid){
    let _userDeleteByIdUri=userDeleteByIdUri.replace('{userid}',userid)
    return http.delete(_userDeleteByIdUri)
}

// 添加用户
export function userAddAPI(params){
    return http.post(userAddUri,params)
}

//修改当前用户密码
export function userChangePassAPI(params){
    return http.post(userChangePassUri,params)
}

//获取角色列表
export function roleListAPI(params){
    return http.get(roleListUri,params)
}

//修改指定角色信息
export function roleModifyByIdAPI(roleid,params){
    let _roleModifyByIdUri=roleModifyByIdUri.replace('{roleid}',roleid)
    return http.post(_roleModifyByIdUri,params)
}

//删除指定角色信息
export function roleDeleteByIdAPI(roleid){
    let _roleDeleteByIdUri=roleDeleteByIdUri.replace('{roleid}',roleid)
    return http.delete(_roleDeleteByIdUri)
}

// 添加角色
export function roleAddAPI(params){
    return http.post(roleAddUri,params)
}

//获取权限列表-分页
export function securityListAPI(params){
    return http.get(securityListUri,params)
}

//获取权限列表-不分页
export function securityAllAPI(){
    return http.get(securityAllUri)
}
//获取角色拥有权限
export function roleSecurityAPI(roleid){
    let _roleSecurityUri=roleSecurityUri.replace('{roleid}',roleid)
    return http.get(_roleSecurityUri)
}

//为角色分配权限
export function securityGiveRoleAPI(roleid,params){
    let _securityGiveRoleUri=securityGiveRoleUri.replace('{roleid}',roleid)
    return http.post(_securityGiveRoleUri+params)
}

//获取角色列表-不分页
export function roleAllAPI(){
    return http.get(roleAllUri)
}
//获取用户拥有角色
export function userRoleAPI(userid){
    let _userRoleUri=userRoleUri.replace('{userid}',userid)
    return http.get(_userRoleUri)
}

//为用户分配角色
export function roleGiveUserAPI(userid,params){
    let _roleGiveUserUri=roleGiveUserUri.replace('{userid}',userid)
    return http.post(_roleGiveUserUri+params)
}

//获取数据字典分类列表-不分页
export function sysCategoryAllAPI(){
    return http.get(sysCategoryAllUri)
}

//获取数据字典分类详细信息
export function sysCategoryInfoAPI(categoryid){
    let _sysCategoryInfoUri=sysCategoryInfoUri.replace('{categoryid}',categoryid)
    return http.get(_sysCategoryInfoUri)
}

//修改数据字典分类
export function sysCategoryModifyAPI(categoryid,params){
    let _sysCategoryModifyUri=sysCategoryModifyUri.replace('{categoryid}',categoryid)
    return http.post(_sysCategoryModifyUri,params)
}

//添加数据字典分类
export function sysCategoryAddAPI(params){
    return http.post(sysCategoryAddUri,params)
}

//根据类别获取数据字典列表
export function sysDataByCateIdAPI(categoryid){
    let _sysDataByCateIdUri=sysDataByCateIdUri.replace('{categoryid}',categoryid)
    return http.get(_sysDataByCateIdUri)
}

//添加数据字典
export function sysDataAddAPI(categoryid,params){
    let _sysDataAddUri=sysDataAddUri.replace('{categoryid}',categoryid)
    return http.post(_sysDataAddUri,params)
}

//删除指定数据字典
export function sysDataDeleteAPI(categoryid,params){
    let _sysDataDeleteUri=sysDataDeleteUri.replace('{categoryid}',categoryid)
    return http.delete(_sysDataDeleteUri+params)
}

//修改数据字典分类
export function sysDataModyfyByIdAPI(categoryid,dataid,params){
    let _sysDataModyfyByIdUri=sysDataModyfyByIdUri.replace('{categoryid}',categoryid).replace('{dataid}',dataid)
    return http.put(_sysDataModyfyByIdUri,params)
}